import pandas as pd

data = {

    'A': [1, 0, 1, 1],
    'B': [0, 2, 5, 0],
    'C': [4, 0, 4, 4],
    'D': [1, 0, 1, 1]
}
df = pd.DataFrame(data=data)
print(df)

print(df.sort_index(ascending=False))
print(df.sort_index(axis=1))
print(df.sort_values(by='A'))
print(df.sort_values(by='B', kind='mergesort'))  # heapsort  quicksort

# 去重
print(df.drop_duplicates())
print(df.drop_duplicates(subset=['B'], keep=False))
# 两列同时重复 去掉一列
print(df.drop_duplicates(['A', 'B'], keep='last'))
print(df.reset_index(drop=True))
